﻿
using System;
using System.Collections.Generic;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;
using System.Text;
using System.IO;
using System.Web.UI.HtmlControls;


using BLL;
using DAL;
using Models;
using System.Xml;
using Web.Old_App_Code;

using Gift.DAL;
using Gift.Model;


public partial class cn_goods :  BasePage
{
    // Fields
    protected ArticleManager am = new ArticleManager();
    protected ArticleTypeManager atm = new ArticleTypeManager();
    protected CommentReplyManager crm = new CommentReplyManager();
    protected CommodityScoreManager csm = new CommodityScoreManager();

    protected FreightWayManager fwm = new FreightWayManager();
    protected GoodsAttributeManager gam = new GoodsAttributeManager();
    protected GoodsCommentManager gcm = new GoodsCommentManager();
    protected GoodsEntitysManager gem = new GoodsEntitysManager();
    protected GoodsEntitysSpecificationsManager gesm = new GoodsEntitysSpecificationsManager();
    protected GoodGalleryManager ggm = new GoodGalleryManager();
    protected GoodsManager gm = new GoodsManager();
    protected string goodsCommentXmlPath = "/cn/xml/goods_comment.xml";

    protected RegionManager rm = new RegionManager();
    protected UserBrowse ub = new UserBrowse();
    protected UserBrowseManager ubm = new UserBrowseManager();

    readonly DALShoppro theShoppro = new DALShoppro();
    readonly DALGoodsScore theGoodsScore = new DALGoodsScore();
    readonly DALGoodsComment theGoodsComment = new DALGoodsComment();
    DB_Shoppro oShoppro;

    // Methods
    protected StringBuilder CategoryTopSellingBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            oShoppro = theShoppro.GetModel(Convert.ToInt32(base.Request.QueryString["id"]));
            DataTable table = theShoppro.GetSellTop10Products(oShoppro.typeid);
            if (table.Rows.Count <= 0)
            {
                return builder;
            }
            builder.AppendLine("<div class=\"sidelist\">");
            builder.AppendLine("<h6><strong>同类最热销</strong></h6>");
            builder.AppendLine("<ul>");
            foreach (DataRow row in table.Rows)
            {
                builder.AppendLine("<li>");
                string picUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + row["prosmallpic"];
                builder.AppendLine(string.Concat(new object[] { "<a href=\"?id=", row["proid"], "\"><img src=\"", picUrl, "\" alt=\"", row["proName"], "\" /></a>" }));
                builder.AppendLine(string.Concat(new object[] { "<p><a href=\"?id=", row["proid"], "\" title=\"", row["proname"], "\">", row["proName"], "</a><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row["saleprice"])), "</strong></em></p>" }));
                builder.AppendLine("</li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }



    protected string DescriptionBind()
    {
        string str = "";
        try
        {
            if (base.Request.QueryString["id"] == null)
            {
                return str;
            }
            oShoppro = theShoppro.GetModel(Convert.ToInt32(base.Request.QueryString["id"]));
            if (oShoppro != null)
            {
                str = oShoppro.proname;
            }
            if (str != "")
            {
                str = str + "，";
            }
        }
        catch
        {
        }
        return str;
    }

    protected StringBuilder GoodGalleryBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
   
            if (base.Request.QueryString["id"] != null)
            {
                oShoppro = theShoppro.GetModel(Convert.ToInt32(base.Request.QueryString["id"]));
               
            }
            builder.AppendLine("<div class=\"proimg\">");
            builder.AppendLine("<div class=\"zoom-section\">");
            builder.AppendLine("<div class=\"zoom-small-image\">");
            if (oShoppro != null)
            {
                string picBigUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + oShoppro.probigpic;
                string picUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + oShoppro.prosmallpic;
                builder.AppendLine(string.Concat(new object[] { "<a href=\"", picBigUrl, "\" class=\"cloud-zoom\" id=\"zoom1\" rel=\"adjustX: 10, adjustY:-4\"><img src=\"", picUrl, "\" alt=\"", oShoppro.proname, "\" /></a>" }));
            }
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"zoom-desc\">");
            builder.AppendLine("<div class=\"infiniteCarousel\">");
            builder.AppendLine("<div class=\"wrapper\">");
            builder.AppendLine("<ul>");
            if (oShoppro != null)
            {
                string picBigUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + oShoppro.probigpic;
                string picUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + oShoppro.prosmallpic;
                builder.AppendLine("<li>");
                builder.AppendLine(string.Concat(new object[] { "<a href=\"", picBigUrl, "\" class=\"cloud-zoom-gallery\" title=\"", oShoppro.proname, "\" rel=\"useZoom: 'zoom1', smallImage: '", picUrl, "'\"><img class=\"zoom-tiny-image\" src=\"", picBigUrl, "\" alt=\"", oShoppro.proname, "\" /></a>" }));
                builder.AppendLine("</li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("<script type=\"text/javascript\" src=\"" + new TemplateLoad().TemplateCssLoad() + "js/showpro/marque.js\"></script>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder GoodsDetailedBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            double num2;
            int id = 0;
            if (base.Request.QueryString["id"] != null)
            {
                id = Convert.ToInt32(base.Request.QueryString["id"]);
            }
            builder.AppendLine("<div class=\"main\">");
            builder.AppendLine("<div class=\"content-box\">");
            builder.AppendLine("<div class=\"content-box-header\">");
            builder.AppendLine("<ul class=\"content-box-tabs\">");
            builder.AppendLine("<li><a href=\"#tab1\" class=\"default-tab\">商品介绍</a></li>");
            builder.AppendLine("<li><a href=\"#tab2\" name=\"proarrt\" class=\"morearrt\">规格参数</a></li>");
            builder.AppendLine("<li><a href=\"#tab3\">商品评价</a></li>");
            builder.AppendLine("<li><a href=\"#tab4\">选购指南</a></li>");
            builder.AppendLine("<li><a href=\"#tab5\">售后服务</a></li>");
            builder.AppendLine("<li><a href=\"#tab6\">如何购买</a></li>");
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"content-box-content\">");
            builder.AppendLine("<div class=\"tab-content default-tab\" id=\"tab1\">");
            builder.AppendLine("<h3>商品介绍：</h3>");
            builder.AppendLine("<div class=\"tabcontain\">");

            if (base.Request.QueryString["id"] != null)
            {
                oShoppro = theShoppro.GetModel(Convert.ToInt32(base.Request.QueryString["id"]));

            }
            if (oShoppro != null)
            {
                builder.AppendLine("<div class=\"tabcontain\">" + oShoppro.procontent + "</div>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"tab-content\" id=\"tab2\">");
            builder.AppendLine("<h3>规格参数</h3>");
            builder.AppendLine("<div class=\"arrtinto\">");
            builder.AppendLine("<table>");
            DataTable table2 = this.gam.FrontDeskGetGoodsAttributeByGoodAndTop(id, 0);
            foreach (DataRow row in table2.Rows)
            {
                builder.AppendLine("<tr>");
                builder.AppendLine("<td class=\"first_td\">" + row["attributeName"] + "：</td>");
                builder.AppendLine("<td>" + row["inputValue"] + "</td>");
                builder.AppendLine("</tr>");
            }
            builder.AppendLine("</table>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"tab-content\" id=\"tab3\">");
            DataTable tbCommentScore = theGoodsScore.GetGoodsScoreByGoods(id);
            builder.AppendLine("<div class=\"comment_star tabcontain\">");
            builder.AppendLine("<div class=\"contain_star\"  id=\"divScore\">");
            builder.AppendLine("<div>");
            builder.AppendLine("<p><em>宝贝与描述相符</em></p>");
            builder.AppendLine("<p>");
            DataRow row2 = tbCommentScore.Rows[0];
            string str = row2["scores"].ToString();
            if (!Convert.IsDBNull(row2["scores"]))
            {
                num2 = Convert.ToDouble(row2["scores"]);
                if ((num2 >= 1.0) && (num2 < 1.5))
                {
                    builder.AppendLine("<strong>1</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star01.gif\" /></p>");
                }
                else if ((num2 >= 1.5) && (num2 < 2.0))
                {
                    builder.AppendLine("<strong>1.5</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star015.gif\" /></p>");
                }
                else if ((num2 >= 2.0) && (num2 < 2.5))
                {
                    builder.AppendLine("<strong>2</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star02.gif\" /></p>");
                }
                else if ((num2 >= 2.5) && (num2 < 3.0))
                {
                    builder.AppendLine("<strong>2.5</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star025.gif\" /></p>");
                }
                else if ((num2 >= 3.0) && (num2 < 3.5))
                {
                    builder.AppendLine("<strong>3</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star03.gif\" /></p>");
                }
                else if ((num2 >= 3.5) && (num2 < 4.0))
                {
                    builder.AppendLine("<strong>3.5</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star035.gif\" /></p>");
                }
                else if ((num2 >= 4.0) && (num2 < 4.5))
                {
                    builder.AppendLine("<strong>4</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star04.gif\" /></p>");
                }
                else if ((num2 >= 4.5) && (num2 < 5.0))
                {
                    builder.AppendLine("<strong>4.5</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star045.gif\" /></p>");
                }
                else if (num2 == 5.0)
                {
                    builder.AppendLine("<strong>5</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star05.gif\" /></p>");
                }
            }
            else
            {
                builder.AppendLine("<strong>0</strong>分<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star00.gif\" /></p>");
            }
            builder.AppendLine("<p>(已有<span>" + row2["scoresNumber"] + "</span>人进行评分)</p>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"second_img\">");
            if (!Convert.IsDBNull(row2["scores"]))
            {
                num2 = Convert.ToDouble(row2["scores"]);
                if ((num2 >= 1.0) && (num2 < 1.5))
                {
                    builder.AppendLine("<strong style=\"right: 330px;\">1</strong>");
                }
                else if ((num2 >= 1.5) && (num2 < 2.0))
                {
                    builder.AppendLine("<strong style=\"right: 290px;\">1.5</strong>");
                }
                else if ((num2 >= 2.0) && (num2 < 2.5))
                {
                    builder.AppendLine("<strong style=\"right: 250px;\">2</strong>");
                }
                else if ((num2 >= 2.5) && (num2 < 3.0))
                {
                    builder.AppendLine("<strong style=\"right: 210px;\">2.5</strong>");
                }
                else if ((num2 >= 3.0) && (num2 < 3.5))
                {
                    builder.AppendLine("<strong style=\"right: 170px;\">3</strong>");
                }
                else if ((num2 >= 3.5) && (num2 < 4.0))
                {
                    builder.AppendLine("<strong style=\"right: 130px;\">3.5</strong>");
                }
                else if ((num2 >= 4.0) && (num2 < 4.5))
                {
                    builder.AppendLine("<strong style=\"right:90px;\">4</strong>");
                }
                else if ((num2 >= 4.5) && (num2 < 5.0))
                {
                    builder.AppendLine("<strong style=\"right: 50px;\">4.5</strong>");
                }
                else if (num2 == 5.0)
                {
                    builder.AppendLine("<strong style=\"right: 10px;\">5</strong>");
                }
            }
            else
            {
                builder.AppendLine("<strong style=\"right: 410px;\">0</strong>");
            }
            builder.AppendLine("<img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/score.gif\" alt=\"星级标尺\" />");
            builder.AppendLine("</div>");
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine("</div>");
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.goodsCommentXmlPath));
            XmlElement element = document.SelectSingleNode("comment") as XmlElement;
            if (element.GetAttribute("isBuyComment") == "true")
            {
                builder.AppendLine("<form id=\"formScore\" action=\"\" defaultbutton=\"btnScoreSubmit\"><ul>");
                builder.AppendLine("<li class=\"first_li\">商品评分：</li>");
                builder.AppendLine("<li><input type=\"radio\" name=\"commodityScore\" value=\"1\" /><img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star01.gif\" alt=\"一星级\" /></li>");
                builder.AppendLine("<li><input type=\"radio\" name=\"commodityScore\" value=\"2\" /><img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star02.gif\" alt=\"二星级\" /></li>");
                builder.AppendLine("<li><input type=\"radio\" name=\"commodityScore\" value=\"3\" /><img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star03.gif\" alt=\"三星级\" /></li>");
                builder.AppendLine("<li><input type=\"radio\" name=\"commodityScore\" value=\"4\" /><img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star04.gif\" alt=\"四星级\" /></li>");
                builder.AppendLine("<li><input type=\"radio\" name=\"commodityScore\" value=\"5\" /><img src=\"" + new TemplateLoad().TemplateCssLoad() + "images/star05.gif\" alt=\"五星级\" /></li>");
                builder.AppendLine("<li><input id=\"btnScoreSubmit\" class=\"btn\" type=\"submit\" value=\"提交评分\" /></li>");
                builder.AppendLine("</ul></form>");
            }
            builder.AppendLine("</div>");
            DataTable oGoodsCommentByProIdAndTop = theGoodsComment.GetGoodsCommentByProIdAndTop(id, 0);
            builder.AppendLine("<div class=\"comment_title\">");
            builder.AppendLine((("" + element.GetAttribute("isBuyComment")) == "true") ? "<a href=\"#comment\">我要评价</a>" : ("<span>商品评价 共<strong>" + oGoodsCommentByProIdAndTop.Rows.Count + "</strong>条</span>"));
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"tabcontain\" id=\"goods_comment\">");
            builder.AppendLine("<ul class=\"comment_list\">");
            foreach (DataRow row in oGoodsCommentByProIdAndTop.Rows)
            {
                builder.AppendLine("<li>");
                builder.AppendLine(string.Concat(new object[] { "<h5>", row["userName"], " <span>", Convert.ToDateTime(row["commentTime"]).ToString("yyyy-MM-dd HH:mm:ss"), " / IP：", row["commentIP"], "</span></h5>" }));
                builder.AppendLine("<p>" + row["content"] + "</p>");
                builder.AppendLine("</li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine("<a name=\"comment\"></a>");
            if (element.GetAttribute("isBuyComment") == "true")
            {
                builder.AppendLine("<h3>我要评价：</h3>");
                builder.AppendLine("<div class=\"tabcontain comment_list\">");
                builder.AppendLine("<form id=\"formComment\" action=\"\" defaultbutton=\"btnGoodsComment\" >");
                builder.AppendLine("<p><label for=\"txtaContent\">评论内容：</label><textarea id=\"txtaContent\" name=\"content\"></textarea><span id=\"spContent\">*最多可输入200个字符</span></p>");
                builder.AppendLine("<p><label for=\"txtContact\">联系方式：</label><input id=\"txtContact\" name=\"contact\" type=\"text\" maxlength=\"50\" /><span> 最多可输入50个字符</span></p>");
                builder.AppendLine("<label for=\"txtCommentCode\">验证码：</label><input id=\"txtCommentCode\" type=\"text\" maxlength=\"4\" /><img id=\"imgCheckCommentCode\" class=\"imgCode\" src=\"/code.aspx?t=conmment\" alt=\"看不清楚,换一张\" onclick=\"this.src = '/code.aspx?a=' + Math.random();+'&t=conmment'\" /><span id=\"spCommentCode\"></span>");
                builder.AppendLine("<p><input id=\"btnGoodsComment\" class=\"submit\" type=\"submit\" value=\"确定提交\" /></p>");
                builder.AppendLine("</form>");
                builder.AppendLine("</div>");
            }
            builder.AppendLine("<input id=\"hdGoods\" type=\"hidden\" value=\"" + id + "\" /></div>");
            string parentId = this.atm.GetArticleTypeByTypeNameAndParentIdAndLanguageVersion("帮助中心", "00000000-0000-0000-0000-000000000000", "zh-CN");
            builder.AppendLine("<div class=\"tab-content\" id=\"tab4\">");
            string articleTypeId = this.atm.GetIdByTypeNameAndParentIdAndLanguageVersionAndIsShow("选购指南", parentId, "zh-CN", 1);
            DataTable atricleByArticleTypeIdAndTop = this.am.GetAtricleByArticleTypeIdAndTop(articleTypeId, 5);
            foreach (DataRow row in atricleByArticleTypeIdAndTop.Rows)
            {
                builder.AppendLine("<h3>" + row["articleTilte"] + "</h3>");
                builder.AppendLine("<div class=\"tabcontain\">" + row["articleContent"].ToString() + "</div>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"tab-content\" id=\"tab5\">");
            string str4 = this.atm.GetIdByTypeNameAndParentIdAndLanguageVersionAndIsShow("售后服务", parentId, "zh-CN", 1);
            DataTable table6 = this.am.GetAtricleByArticleTypeIdAndTop(str4, 5);
            foreach (DataRow row in table6.Rows)
            {
                builder.AppendLine("<h3>" + row["articleTilte"] + "</h3>");
                builder.AppendLine("<div class=\"tabcontain\">" + row["articleContent"].ToString() + "</div>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"tab-content\" id=\"tab6\">");
            string str5 = this.atm.GetIdByTypeNameAndParentIdAndLanguageVersionAndIsShow("如何购买", parentId, "zh-CN", 1);
            DataTable table7 = this.am.GetAtricleByArticleTypeIdAndTop(str5, 5);
            foreach (DataRow row in table7.Rows)
            {
                builder.AppendLine("<h3>" + row["articleTilte"] + "</h3>");
                builder.AppendLine("<div class=\"tabcontain\">" + row["articleContent"].ToString() + "</div>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder GoodsEntitysBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            int id = 0;
            DataTable shelvesGoodsById = new DataTable();
            if (base.Request.QueryString["id"] != null)
            {
                id = Convert.ToInt32(base.Request.QueryString["id"]);
             //   shelvesGoodsById = this.gm.GetShelvesGoodsById(id);
                oShoppro = theShoppro.GetModel(id);
            }
            builder.AppendLine("<div class=\"proattr\">");
            if (oShoppro != null)
            {
                int num3;
             //   DataRow row = shelvesGoodsById.Rows[0];
                builder.AppendLine("<h1>" + oShoppro.proname + "</h1>");
               // DataTable goodsEntitysByGoods = this.gem.GetGoodsEntitysByGoods(id);
                builder.AppendLine(string.Concat(new object[] { "<p class=\"productcode\">商品编号：",oShoppro.shopId.ToString(), " <span id=\"goodsArtno\">商品货号：", oShoppro.procode, "</span></p>" }));
                //if (goodsEntitysByGoods.Rows.Count > 0)
                //{
                    builder.AppendLine("<p class=\"saleprice\" id=\"pPrice\">会员价：<strong>" + string.Format("{0:C}", oShoppro.saleprice) + "</strong> <del>市场价：" + string.Format("{0:C}", oShoppro.marketprice) + "</del></p>");
               // }
                if (oShoppro.Scores !=0 )
                {
                    double num2 = Convert.ToDouble(oShoppro.Scores.ToString());
                    if ((num2 < 1.5) && (num2 >= 1.0))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star01.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if ((num2 < 2.0) && (num2 >= 1.5))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star015.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if ((num2 < 2.5) && (num2 >= 2.0))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star02.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if ((num2 < 3.0) && (num2 >= 2.5))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star025.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if ((num2 < 3.5) && (num2 >= 3.0))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star03.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if ((num2 < 4.0) && (num2 >= 3.5))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star035.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if ((num2 < 4.5) && (num2 >= 4.0))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star04.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if ((num2 < 5.0) && (num2 >= 4.5))
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star045.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                    else if (num2 == 5.0)
                    {
                        builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star05.gif\" /><span>(已有", oShoppro.ScoreNumber.ToString(), "人评论)</span></p>" }));
                    }
                }
                else
                {
                    builder.AppendLine(string.Concat(new object[] { "<p id=\"pScore\">用户综合评分：<img src=\"", new TemplateLoad().TemplateCssLoad(), "images/star00.gif\" /><span>(已有", oShoppro.saleprice.ToString(), "人评论)</span></p>" }));
                }
                builder.AppendLine("<ul class=\"proarrtinto\">");
                DataTable table3 = this.gam.FrontDeskGetGoodsAttributeByGoodAndTop(id, 6);
                for (num3 = 0; num3 < table3.Rows.Count; num3++)
                {
                    builder.AppendLine(string.Concat(new object[] { "<li>", table3.Rows[num3]["attributeName"], "：<span>", table3.Rows[num3]["inputValue"], "</span></li>" }));
                }
                builder.AppendLine("</ul>");
                builder.AppendLine("<p class=\"textright\"><a href=\"#proarrt\" id=\"proarrt\">更多属性</a></p>");
                builder.AppendLine("<ul>");
                DataTable table4 = this.gesm.FrontDeskGetGoodsEntitysSpecificationsByGoods(id);
                if (table4.Rows.Count > 0)
                {
                    DataRow current;
                    builder.AppendLine("<li id=\"liChooseSpecifications\">");
                    ArrayList list = new ArrayList();
                    ArrayList list2 = new ArrayList();
                    builder.AppendLine("已选择：");
                    ArrayList list3 = new ArrayList();
                    bool flag = false;


                    System.Collections.IEnumerator enumerator = table4.Rows.GetEnumerator();

                        while (enumerator.MoveNext())
                        {
                            current = (DataRow)enumerator.Current;
                            if (!list3.Contains(Convert.ToInt32(current["specifications"])))
                            {
                                builder.AppendLine((!flag ? "" : "&nbsp;&nbsp;") + current["specificationsValueName"].ToString());
                                list3.Add(Convert.ToInt32(current["specifications"]));
                                flag = true;
                            }
                        }
                        if (enumerator != null)
                        {
                            enumerator = null;
                        }
                    
                    builder.AppendLine("</li>");
                    builder.AppendLine("<li id=\"liSpecifications\">");
                    for (num3 = 0; num3 < table4.Rows.Count; num3++)
                    {
                        current = table4.Rows[num3];
                        if (Convert.ToInt32(current["specificationsType"]) == 0)
                        {
                            if (!list.Contains(Convert.ToInt32(current["specifications"])))
                            {
                                builder.AppendLine(((num3 != 0) ? "<br />" : "") + current["specificationsName"] + "：");
                                list.Add(Convert.ToInt32(current["specifications"]));
                            }
                            if (!list2.Contains(Convert.ToInt32(current["specificationsValue"])))
                            {
                                builder.AppendLine(string.Concat(new object[] { "<strong  ", (current["goodsEntitys"].ToString() == table4.Rows[0]["goodsEntitys"].ToString()) ? "class='selectStrong'" : "class='strong'", " onclick='chooseSpecifications(\"", current["goodsEntitys"], "\",\"", current["specifications"], "\",\"", current["specificationsValue"], "\");'>", current["specificationsValueName"], "</strong>" }));
                                list2.Add(Convert.ToInt32(current["specificationsValue"]));
                            }
                        }
                        else
                        {
                            if (!list.Contains(Convert.ToInt32(current["specifications"])))
                            {
                                builder.AppendLine(((num3 != 0) ? "<br />" : "") + current["specificationsName"] + "：");
                                list.Add(Convert.ToInt32(current["specifications"]));
                            }
                            if (!list2.Contains(Convert.ToInt32(current["specificationsValue"])))
                            {
                                builder.AppendLine(string.Concat(new object[] { "<span onclick='chooseSpecifications(\"", current["goodsEntitys"], "\",\"", current["specifications"], "\",\"", current["specificationsValue"], "\");'><img ", (current["goodsEntitys"].ToString() == table4.Rows[0]["goodsEntitys"].ToString()) ? "class='selectStrong'" : "class='strong'", " src=\"", current["specificationsValueImage"], "\" alt=\"", current["specificationsValueName"], "\" /></span>" }));
                                list2.Add(Convert.ToInt32(current["specificationsValue"]));
                            }
                        }
                    }
                    builder.AppendLine("</li>");
                }
                builder.AppendLine("<li>");
                //builder.AppendLine(string.Concat(new object[] { "<p class=\"number\">数量：<input id=\"btnCountJian\" type=\"button\" value=\"-\" /><span><input id=\"txtCount\" type=\"text\" value=\"", (Convert.ToInt32(goodsEntitysByGoods.Rows[0]["inventory"]) > 0) ? "1" : "0", "\" maxlength=\"5\" onkeyup=\"value=value.replace(/[^\\d]/g,'')\" onbeforepaste=\"clipboardData.setData('text',clipboardData.getData('text').replace(/[^\\d]/g,''))\" /></span><input id=\"btnCountJia\" type=\"button\" value=\"+\" /> [库存<span id=\"spInventory\">", goodsEntitysByGoods.Rows[0]["inventory"], "</span>件]</p>" }));
                builder.AppendLine(string.Concat(new object[] { "<p class=\"number\">数量：<input id=\"btnCountJian\" type=\"button\" value=\"-\" /><span><input id=\"txtCount\" type=\"text\" value=\"",  "1" , "\" maxlength=\"5\" onkeyup=\"value=value.replace(/[^\\d]/g,'')\" onbeforepaste=\"clipboardData.setData('text',clipboardData.getData('text').replace(/[^\\d]/g,''))\" /></span><input id=\"btnCountJia\" type=\"button\" value=\"+\" /> [库存<span id=\"spInventory\">", string.Empty, "</span>件]</p>" }));
                builder.AppendLine("<a id=\"aAddShoppingCart\" class=\"shopcart\" href=\"#\"></a><a id=\"aFavorites\" class=\"addto\" href=\"#\" title=\"收藏该商品\"></a>");
                builder.AppendLine("</li>");
                builder.AppendLine("<li>");
                //if (Convert.ToInt32(row["isFromFreight"]) == 1)
                //{
                //    builder.AppendLine("<p><strong>运费：</strong>卖家承担运费</p>");
                //}
                //else
                //{
                //    DataTable freightWayByFreightTemplate = this.fwm.GetFreightWayByFreightTemplate(Convert.ToInt32(row["freightTemplate"]));
                //    bool flag2 = false;
                //    string str = "";
                //    foreach (DataRow row2 in freightWayByFreightTemplate.Rows)
                //    {
                //        if (row2["region"].ToString() == "0")
                //        {
                //            flag2 = true;
                //            break;
                //        }
                //    }
                //    builder.AppendLine("<p class=\"float\"><strong>运费：</strong></p>");
                //    builder.AppendLine("<ul id=\"summary\">");
                //    builder.AppendLine("<script type=\"text/javascript\">$(document).ready(function (){$('#storeinfo').hover(function(){ $(this).addClass('hover');},function(){$(\"a[s]\").removeClass('sbg');$(\".city\").hide();$(this).removeClass('hover');});});</script>");
                //    builder.AppendLine("<li id=\"storeinfocontainer\" style=\"display: list-item;\"><span class=\"float\">送至</span>");
                //    builder.AppendLine("<div id=\"storeinfo\">");
                //    builder.AppendLine("<div class=\"i-storeinfo\">");
                //    if (flag2)
                //    {
                //        builder.AppendLine("<div id=\"region\">全国</div>");
                //    }
                //    else
                //    {
                //        foreach (DataRow row2 in freightWayByFreightTemplate.Rows)
                //        {
                //            builder.AppendLine("<div id=\"region\">" + row2["region"].ToString().Split(new char[] { ',' }).GetValue(0).ToString() + "</div>");
                //            str = row2["region"].ToString().Split(new char[] { ',' }).GetValue(0).ToString();
                //            break;
                //        }
                //    }
                //    builder.AppendLine("</div>");
                //    builder.AppendLine("<dl>");
                //    builder.AppendLine("<iframe style=\"position: absolute; z-index: -1; width: 340px; height: 28px; top: 170px; left: 66px;\" scrolling=\"no\" frameborder=\"0\"></iframe>");
                //    builder.AppendLine("<dd>");
                //    DataTable regionByParentRegionAndLanguageVersion = this.rm.GetRegionByParentRegionAndLanguageVersion(0, "zh-CN");
                //    builder.AppendLine("<ul><li class=\"prov\"><a href=\"javascript:;\" s=\"0\" onclick=\"changeFreight('" + row["freightTemplate"] + "','0','全国');\">全部</a> </li></ul>");
                //    foreach (DataRow row2 in regionByParentRegionAndLanguageVersion.Rows)
                //    {
                //        builder.AppendLine(string.Concat(new object[] { "<ul><li class=\"prov\"><a href=\"javascript:;\" s=\"", row2["id"], "\" onclick=\"changeFreight('", row["freightTemplate"], "','", row2["regionName"], "','", row2["regionName"], "');\">", row2["regionName"], "</a> </li></ul>" }));
                //    }
                //    builder.AppendLine("</dd>");
                //    builder.AppendLine("</dl>");
                //    builder.AppendLine("</div>");
                //    builder.AppendLine("</li>");
                //    builder.AppendLine("</ul>");
                //    builder.AppendLine("<p id=\"pFreight\" class=\"last\">");
                //    ArrayList list4 = new ArrayList();
                //    foreach (DataRow row2 in freightWayByFreightTemplate.Rows)
                //    {
                //        if (flag2)
                //        {
                //            if (!(list4.Contains(Convert.ToInt32(row2["deliveryWayId"])) || !(row2["region"].ToString() == "0")))
                //            {
                //                builder.Append(string.Concat(new object[] { "<span>", row2["deliveryWay"], ":", Convert.ToDecimal(row2["defaultFreight"]).ToString("0.0"), "元</span>" }));
                //                list4.Add(Convert.ToInt32(row2["deliveryWayId"]));
                //            }
                //        }
                //        else if (!(list4.Contains(Convert.ToInt32(row2["deliveryWayId"])) || !row2["region"].ToString().Contains(str)))
                //        {
                //            builder.Append(string.Concat(new object[] { "<span>", row2["deliveryWay"], ":", Convert.ToDecimal(row2["defaultFreight"]).ToString("0.0"), "元</span>" }));
                //            list4.Add(Convert.ToInt32(row2["deliveryWayId"]));
                //        }
                //    }
                //    builder.Append("</p>");
                //}
                builder.AppendLine("<span class=\"clear\"></span>");
                builder.AppendLine("<p>促销活动：</p>");
                //builder.AppendLine("<p  class=\"productcode\">");
                //builder.AppendLine("<img " + ((Convert.ToInt32(row["isOrderFromFreight"]) == 1) ? ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seled.jpg\" alt=\"参与\"") : ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额免运费&nbsp;");
                //builder.AppendLine("<img " + ((Convert.ToInt32(row["isDiscount"]) == 1) ? ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seled.jpg\" alt=\"参与\"") : ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额打折&nbsp;");
                //builder.AppendLine("<img " + ((Convert.ToInt32(row["isTotalReduce"]) == 1) ? ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seled.jpg\" alt=\"参与\"") : ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额减少&nbsp;");
                //builder.AppendLine("<img " + ((Convert.ToInt32(row["isGifts"]) == 1) ? ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seled.jpg\" alt=\"参与\"") : ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额赠送礼品&nbsp;");
                //builder.AppendLine("<img " + ((Convert.ToInt32(row["isSendIntegral"]) == 1) ? ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seled.jpg\" alt=\"参与\"") : ("src=\"" + new TemplateLoad().TemplateCssLoad() + "images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额赠送积分");
                //builder.AppendLine("</p>");
                builder.AppendLine("<span class=\"clear\"></span>");
                builder.AppendLine("<p>");
                builder.AppendLine("<em>分享到：</em>");
                builder.AppendLine("<span id=\"ckepop\"><a class=\"jiathis_button_qzone\">QQ空间</a> <a class=\"jiathis_button_tsina\">新浪微博</a> <a class=\"jiathis_button_tools_1\"></a><a class=\"jiathis_button_tools_2\"></a><a href=\"http://www.jiathis.com/share/\" class=\"jiathis jiathis_txt jiathis_separator jtico jtico_jiathis\" target=\"_blank\">更多</a> </span>");
                builder.AppendLine("<script type=\"text/javascript\" src=\"http://v2.jiathis.com/code/jia.js\" charset=\"utf-8\"></script>");
                builder.AppendLine("</p>");
                builder.AppendLine("<span class=\"clear\"></span>");
                builder.AppendLine("</li>");
                builder.AppendLine("</ul>");
            }
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected string KeywordsBind()
    {
        string str = "";
        try
        {
            if (base.Request.QueryString["id"] == null)
            {
                return str;
            }
            DataTable goodsById = this.gm.GetGoodsById(Convert.ToInt32(base.Request.QueryString["id"]));
            if (goodsById.Rows.Count > 0)
            {
                str = goodsById.Rows[0]["keywords"].ToString();
            }
            if (str != "")
            {
                str = str + "，";
            }
        }
        catch
        {
        }
        return str;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.IsPostBack && (base.Request.QueryString["id"] != null))
        {
            HttpCookie cookie;
            if (HttpContext.Current.Request.Cookies["recent_browse_goods"] == null)
            {
                cookie = new HttpCookie("recent_browse_goods");
                cookie.Value = base.Request.QueryString["id"];
                cookie.Expires = DateTime.Now.AddDays(30.0);
                cookie.Secure = false;
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
            else
            {
                cookie = HttpContext.Current.Request.Cookies["recent_browse_goods"];
                if (!ArrayList.Adapter(cookie.Value.Split(new char[] { ',' })).Contains(base.Request.QueryString["id"]))
                {
                    cookie.Value = cookie.Value + "," + base.Request.QueryString["id"];
                }
                cookie.Expires = DateTime.Now.AddDays(30.0);
                cookie.Secure = false;
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
            //if (LoginUserMember != null)
            //{
            //    string sName = LoginUserMember.MemberId;
            //}
            if (Session["user"] != null)
            {
                this.ub.User = (Session["user"] as User).Id;
                this.ub.Goods = Convert.ToInt32(base.Request.QueryString["id"]);
                this.ubm.AddUserBrowse(this.ub);
            }
        }
    }



    protected StringBuilder RecentBrowseBoodsBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (HttpContext.Current.Request.Cookies["recent_browse_goods"] == null)
            {
                return builder;
            }
            DataTable table = theShoppro.GetRecentTop10Products(HttpContext.Current.Request.Cookies["recent_browse_goods"].Value); // this.gm.GetRecentBrowseGoodsByIsShelvesAndTopAndLanguageVersion(HttpContext.Current.Request.Cookies["recent_browse_goods"].Value, 1, 10, "zh-CN");
            if (table.Rows.Count <= 0)
            {
                return builder;
            }
            builder.AppendLine("<div class=\"sidelist\">");
            builder.AppendLine("<h6>我最近看过</h6>");
            builder.AppendLine("<ul>");
            foreach (DataRow row in table.Rows)
            {
                string picUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + row["prosmallpic"];
                builder.AppendLine("<li>");
                builder.AppendLine(string.Concat(new object[] { "<a href=\"?id=", row["proid"], "\"><img src=\"", picUrl, "\" alt=\"", row["proName"], "\" /></a>" }));
                builder.AppendLine(string.Concat(new object[] { "<p><a href=\"?id=", row["proid"], "\" title=\"", row["proName"], "\">", row["proName"], "</a><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row["saleprice"])), "</strong></em></p>" }));
                builder.AppendLine("</li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder SetSpecificationsValueList()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataTable table = this.gesm.FrontDeskGetGoodsEntitysSpecificationsByGoods(Convert.ToInt32(base.Request.QueryString["id"]));
            ArrayList list = new ArrayList();
            string str = "";
            string str2 = "";
            bool flag = false;
            if (table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (!list.Contains(Convert.ToInt32(row["specifications"])))
                    {
                        str2 = str2 + (!flag ? "" : ",") + row["specifications"].ToString();
                        str = str + (!flag ? "" : ",") + row["specificationsValue"].ToString();
                        list.Add(Convert.ToInt32(row["specifications"]));
                        flag = true;
                    }
                }
                builder.AppendLine("<input id=\"hdSpecificationsList\" type=\"hidden\" value=\"" + str2 + "\" />");
                builder.AppendLine("<input id=\"hdSpecificationsValueList\" type=\"hidden\" value=\"" + str + "\" />");
                builder.AppendLine("<input id=\"hdGoodsEntitys\" type=\"hidden\" value=\"" + table.Rows[0]["goodsEntitys"] + "\" />");
                return builder;
            }
            DataTable goodsEntitysByGoods = this.gem.GetGoodsEntitysByGoods(Convert.ToInt32(base.Request.QueryString["id"]));
            builder.AppendLine("<input id=\"hdGoodsEntitys\" type=\"hidden\" value=\"" + goodsEntitysByGoods.Rows[0]["id"] + "\" />");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder UserBrowseBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataTable table = this.gm.GetUserBrowseGoodsByGoodsAndIsShelvesAndTopAndLanguageVersion(Convert.ToInt32(base.Request.QueryString["id"]), 1, 10, "zh-CN");
            if (table.Rows.Count <= 0)
            {
                return builder;
            }
            builder.AppendLine("<div class=\"sidelist\">");
            builder.AppendLine("<h6>看过此商品的顾客还看过</h6>");
            builder.AppendLine("<ul>");
            foreach (DataRow row in table.Rows)
            {
                builder.AppendLine("<li>");
                builder.AppendLine(string.Concat(new object[] { "<a href=\"?id=", row["id"], "\"><img src=\"", row["thumbImg"], "\" alt=\"", row["imgAlt"], "\" /></a>" }));
                builder.AppendLine(string.Concat(new object[] { "<p><a href=\"?id=", row["id"], "\" title=\"", row["goodsName"], "\">", row["goodsName"], "</a><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])), "</strong></em></p>" }));
                builder.AppendLine("</li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

}